home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 24 / Mac Magazin and MacEasy Magazine CD - Issue 24.iso / Wissenschaft & Technik / ProgressCDEF ƒ / ProgressCDEF Notes < prev    next >
Text File  |  1996-06-11  |  4KB  |  76 lines

  1. ProgressCDEF Notes
  2.     ProgressCDEF © Andrew Regan, 1996
  3.  
  4. Here is the Finder progress bar-type CDEF that I created originally for the latest version of my program Biorhythms 5.5c but which I am now distributing separately for the benefit of all. 
  5.  
  6. Features
  7.  
  8. ◊    Handles standard progress bar behaviour like in the Finder.
  9. ◊    Handles the so-called ‘barber’s pole’ effect, with mauve/grey slashes, as seen in the Stuffit™ range of programs and others.
  10. ◊    Will draw the progress bar to match the colours from the ‘Colours’ control panel.
  11. ◊    Compatible with Greg Landweber‘s ‘~Aaron’ system extension.
  12.  
  13. Compatibility
  14.  
  15. Whenever the shareware extension ‘~Aaron’ suspects progress bars are being drawn it intervenes to draw its own version instead. However progress bars which do not use the standard mauve/grey will conflict with Aaron and it will be unable to do its stuff.
  16.  
  17. My progress bar solves this problem by first determining whether or not Aaron is installed: if it is then it will allow Aaron to do its special drawing. If not, then my progress bar will use the colours from the ‘Colours’ control panel.
  18.  
  19. Basically if you include ProgressCDEF in your application you need not worry about any of these incompatibility problems.  This is especially useful because Aaron is an otherwise excellent piece of software.
  20.  
  21. Instructions for use
  22.  
  23. The resource file contains the CDEF resource, which currently has an id of 200. Thus to create a progress bar control with it, set the control's procID to 3200. If you use a varCode of 1 (thus a procID of 3201) the control will draw using standard colours: mauve/grey, and not those from the ‘Colours’ control panel.
  24.     If you give the control a varCode greater than or equal to 8, then the control will not respond to being dimmed, otherwise the control will be drawn to reflect its dimmed status.
  25.  
  26. With a refCon less than 1000 the control's value represents how much of the task has been performed. Thus if the maximum value is 100, and the current value 50 then the task is half done, and the control is drawn accordingly.
  27.  
  28. If the refCon is greater than or equal to 1000 the control's value represents the stage of the barber-shop pole. What the value is doesn't really matter, because in order to give the impression of movement this value just needs to be incremented. Just add 1 to the value each time through the loop to move the ‘pole’.
  29.  
  30. Example
  31.  
  32. Here is a brief example, written in C, to demonstrate its capabilities. It is not designed as a complete program but is merely intended as a guide for you to make the most of the ProgressCDEF.
  33.  
  34. // -----------------------------------------------------------------------
  35.  
  36. oldReference = GetControlReference(progressControl);
  37.  
  38. // set it up for using barber's pole by ensuring refCon is >= 1000
  39.  
  40. SetControlReference( progressControl, oldReference + 1000);
  41.  
  42. while (!done)            // keep moving until operation completed
  43. {
  44.         if ( AreWeFinishedYet())                done = true;                                                    // finished with ‘barber’s pole’
  45.         else
  46.         {
  47.                     oldValue = GetControlValue(progressControl);
  48.                     SetControlValue(progressControl, oldValue + 1);            // move the pole continuously
  49.         }
  50. }
  51.  
  52. // we've finished the barber's pole stage, now start moving the progress bar normally
  53.  
  54. SetControlReference( progressControl, oldReference);            // refCon below 1000 again
  55. SetControlValue( progressControl, 0);                                                                        // set the counter back to the start
  56.  
  57. for ( i = 1; i <= 100; ++i)                                                            // count up from 1 to 100
  58. {
  59.         DoOurStuff();
  60.         SetControlValue( progressControl, i);            // our progress bar is now moving left to right.
  61. }
  62.  
  63. // -----------------------------------------------------------------------
  64.  
  65. So there we are: we've seen the barber's pole effect and the standard behaviour and no messing about with moduli and bit manipulation. Couldn't be easier.
  66.  
  67. More information
  68.  
  69. ProgressCDEF was compiled using CodeWarrior 9 Academic, optimised and minimised down to 1860 odd bytes. If you like it you can use it wherever you like, in any of your programs.  There is no registration fee, all I ask is that you e-mail me to say you want to use it. The only conditions are that you do not alter it, manipulate or deconstruct it, or otherwise rename the resource. If you would like source code and a sample program mail me for details.
  70.  
  71. Andrew Regan
  72. 11th June 1996
  73. Coventry, UK
  74.  
  75. E-Mail:        Andrew_G.D._Regan@iconex.mactel.org (preferred)
  76. E-Mail:        ecuue@csv.warwick.ac.uk